//缓存数据
let cache = {
	//初始化数据
	//同步缓存
	setCahe(key, data) {
		uni.setStorageSync(key, data);
	},
	//获取同步缓存
	getCahe(key) {
		return uni.getStorageSync(key);
	},
	//第一次打开应用标记及初始化
	setFrist() {
		let bu = uni.getStorageSync('firtst');
		if (!bu) {
			//初始化处理
			this.tomato();
			//标记
			uni.setStorageSync('firtst', true);
			console.log('欢迎使用');
		} else {
			//非第一次打开应用
		}
	},
	//番茄钟数据默认(25)分钟休息默认(5分钟)
	tomato() {
		//设置时间
		this.setCahe('Tomato_work', 1500);
		this.setCahe('Tomato_rest', 300);
		this.setCahe('buShow', true);
		//设置常亮
		this.setCahe('Solid on', false);
		//设置提示
		this.setCahe('Screensavers', false);
		console.log('数据初始化成功');
	},
	//自定义时间
	setTomato(work, rest) {
		if (work <= 0 && rest <= 0) {
			console.error('设定时间为负数');
			return;
		}
		this.setCahe('Tomato_work', work);
		this.setCahe('Tomato_rest', rest);
	},
	//获取时间
	getTomato() {
		let work = 1500;
		let rest = 180;
		work = this.getCahe('Tomato_work');
		rest = this.getCahe('Tomato_rest')
		if (work === 0 || rest === 0) {
			console.warn('缓存获取异常,请校验数据');
		}
		return {
			work: Number(work),
			rest: Number(rest)
		}
	}

}
export default cache;